{extend name="/layouts/base" /}

{block name="title"}管理轮播 - {$CONFIG->SITE->title}{/block}

{block name="content"}
<div id="manage-banner" class="container-xxl">
    
    <div class="row mt-md-4 mt-2">
        <div class="col-xl-8">
            <div class="card">
                <div class="card-body">
                    
                    <div class="dropdown float-end">
                        <a href="javascript:;" class="dropdown-toggle arrow-none card-drop" data-bs-toggle="dropdown" aria-expanded="false">
                            <i class="mdi mdi-dots-vertical"></i>
                        </a>
                        <div class="dropdown-menu dropdown-menu-end">
                            <a v-on:click="initData('','',true)" href="javascript:;" class="dropdown-item">
                                <i class="mdi mdi-autorenew me-1"></i>刷新
                            </a>
                        </div>
                    </div>
                    
                    <h4 class="header-title">全部轮播</h4>
                    <p class="text-muted font-14 mb-4">
                        目前只有一级分类，后面会增加二级分类
                    </p>
                    
                    <!-- 加载动画 开始 -->
                    <div v-if="is_load" class="table-responsive is_load mb-2 flex-center">
                        <div class="spinner-border text-primary m-1" role="status"></div>
                        <div>加载中...</div>
                    </div>
                    <!-- 加载动画 结束 -->
                    
                    <div v-else-if="!is_load" class="table-responsive-sm">
                        <table class="table custom table-centered mb-0">
                            <thead>
                            <tr>
                                <th>标题</th>
                                <th>描述</th>
                                <th>图片地址</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                                <tr v-for="data in banner.data" :key="data.id">
                                    <td>
                                        <span v-on:click="initData(data.id)" class="cursor">{{data.title}}</span>
                                    </td>
                                    <td>{{data.description}}</td>
                                    <td class="limit"><a :href="data.img" target="_blank">{{data.img}}</a></td>
                                    <td>
                                        <button v-on:click="initData(data.id)" type="button" class="btn btn-light btn-sm mr-1">
                                            <i class="mdi mdi-square-edit-outline"></i>
                                        </button>
                                        <button v-on:click="btnDelete(data.id)" type="button" class="btn btn-light btn-sm">
                                            <i class="mdi mdi-delete-outline"></i>
                                        </button>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    
                    <div class="flex space-between align-items-center mt-2">
                        <div class="d-none d-md-block">
                            共 {{banner.page}} 页 {{banner.count}} 条数据
                        </div>
                        <div v-if="!page_is_load && is_page_show" class="btn-group">
                            <button v-on:click="initData('',1)" type="button" class="btn btn-light btn-sm"><i class="mdi mdi-chevron-left"></i></button>
                            <button v-for="(item, index) in page_list" :key="index" v-on:click="initData('',item)" :class="(page == item) ? 'btn btn-sm btn-primary' : 'btn btn-sm btn-light'">
                                {{item}}
                            </button>
                            <button v-on:click="initData('',banner.page)" type="button" class="btn btn-light btn-sm"><i class="mdi mdi-chevron-right"></i></button>
                        </div>
                    </div>
                    
                </div>
            </div>
        </div>
        <div class="col-xl-4">
            <div class="card">
                <div class="card-body">
                    <h4 class="header-title mb-3">{{title}}</h4>
                    <div class="tab-content mb-0 b-0">
                        <div class="tab-pane fade active show">
                            <div class="row">
                                <div class="col-12">
                                    <img :src="edit.img" class="card-img-top mb-3">
                                    <div class="form-group row mb-3">
                                        <label class="col-md-3 col-form-label">标题</label>
                                        <div class="col-md-9">
                                            <input type="text" class="form-control" v-model="edit.title" placeholder="不填写则不显示" onkeyup>
                                        </div>
                                    </div>
                                    <div class="form-group row mb-3">
                                        <label class="col-md-3 col-form-label">描述</label>
                                        <div class="col-md-9">
                                            <input type="text" class="form-control" placeholder="不填写则不显示" v-model="edit.description" onkeyup>
                                        </div>
                                    </div>
                                    <div class="form-group row mb-3">
                                        <label class="col-3 col-form-label">图片地址</label>
                                        <div class="col-9">
                                            <div class="input-group">
                                                <input v-model="edit.img" type="text" class="form-control" placeholder="填写图片地址或点击按钮上传">
                                                <div class="input-group-append">
                                                    <input v-show="false" v-on:change="upload($event)" type="file" id="input-file" />
                                                    <button v-on:click="clickUpload" class="btn btn-dark" type="button">上传</button>
                                                </div>
                                            </div>
                                            <div v-if="speed != 1 && speed != 0" class="progress-w-percent users-upload-head">
                                                <div class="progress progress-sm">
                                                    <div class="progress-bar" role="progressbar" :style="'width: '+ speed * 100 +'%'" aria-valuenow="72" aria-valuemin="0" aria-valuemax="100"></div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group row mb-2">
                                        <label class="col-3 col-form-label">跳转方式</label>
                                        <div class="col-9 flex align-center">
                                            <div class="custom-control custom-radio mr-2">
                                                <input v-model="jump" value="inside" type="radio" id="customRadio1" name="customRadio" class="form-check-input me-1">
                                                <label class="custom-control-label pointer" for="customRadio1">站内跳转</label>
                                            </div>
                                            <div class="custom-control custom-radio">
                                                <input v-model="jump" value="outside" type="radio" id="customRadio2" name="customRadio" class="form-check-input me-1">
                                                <label class="custom-control-label pointer" for="customRadio2">站外跳转</label>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <div class="col-md-12">
                                            <input v-show="jump == 'outside'" type="text" class="form-control" placeholder="请以http://或https://开头" v-model="edit.url" onkeyup>
                                            <div v-show="jump == 'inside'">
                                                <select id="inside-select2" class="form-control select2" data-bs-toggle="select2"></select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="float-left">
                            
                        </div>
                        <div class="float-right">
                            <input type="button" class="btn btn-info button-next" v-on:click="btnSave(edit.id)" value="保存" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script src="{$CONFIG->ROOT}js/pages/manage-banner.js?v={$CONFIG->VERSION}"></script>
{/block}